import { container, singleton } from "tsyringe";
import { RobotAppPage } from "../../page";
import { Task } from "../../../autox/task";

@singleton()
export class DialogActivity extends RobotAppPage {
    title: string = `弹框`
    private isRuning: boolean = false;
    private task: Task;
    constructor(){
        super();
        this.task = container.resolve(Task)
    }
    dispose(): void {
        this.out()
    }
    is(packageName: string): boolean {
        return `com.smile.gifmaker` === packageName|| `com.kuaishou.nebula` === packageName;
    }
    accept(activityName: string): boolean {
        return `android.app.Dialog` === activityName;
    }
    in(): boolean {
        if (this.isRuning) return;
        this.isRuning = true;
        /**
         * 1. 参加活动
         * 2. 检测开奖
         * 3. 广告关闭
         */
        sleep(500)
        back();
        sleep(500)
        return true;
    }
    out(): boolean {
        if (!this.isRuning) return false;
        this.isRuning = false;
        return true;
    }
}